package com.kyk.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kyk.entity.Restaurants;
import com.kyk.mapper.RestaurantsMapper;
import com.kyk.service.IRestaurantsService;
import com.kyk.util.CodeUtil;
import com.kyk.util.JwtUtils;
import com.kyk.util.Result;
import io.jsonwebtoken.Claims;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 餐厅表 服务实现类
 * </p>
 *
 * @author 凯
 * @since 2025-09-12
 */
@Service
public class RestaurantsServiceImpl extends ServiceImpl<RestaurantsMapper, Restaurants> implements IRestaurantsService {

    @Autowired
    RestaurantsMapper restaurantsMapper;
     @Autowired
     JwtUtils jwtUtils;

    @Override
    public Result getRestaurants(Long merchantId, String userType) {
        // 额外校验：确保用户类型正确（可选，增强安全性）
        if (!"MERCHANT".equals(userType)) {
            return new Result(CodeUtil.PERMISSION_DENIED, "权限错误");
        }

        List<Restaurants> restaurants = restaurantsMapper.selectList(new LambdaQueryWrapper<Restaurants>().eq(Restaurants::getMerchantId, merchantId));
        return new Result(CodeUtil.QUERY_OK, "查询成功", restaurants);
    }
}
